<?php $this->load->view('header'); ?>
<script type="text/javascript">
	$(document).ready(function(){
		$('.delete_icon').click(function(e){
		var konfirm = confirm('Anda yakin ingin menghapus video ini?');
		if(konfirm == true){
			$.ajax({
				type: "POST",
				url: baseUrl+"videos/delete/"+$(e.target).attr('id_video'),
				dataType:'json',
				success: function(){
					$(e.target).closest('tr').remove();
				},
				error:function(){
					console.log('error')
				}
			});
		}
		e.preventDefault();
		});
	});
</script>
 <div id="title_background">
	<div class="wrapper"><!-- 900px wrapper -->
		<h1>Galeri Video</h1>
		<!--<span class="title_description">Daftar video yang telah diunggah.</span>-->
	</div> <!-- 900px wrapper -->
</div>
</div>
<div class="cleaner"></div>
<div id="position_navi"><a href="<?php echo base_url();?>">Beranda</a> / video</div>
<div id="content">
<article>
<h2>Video Anda</h2>
<a href="<?php echo base_url()."videos/add";?>"><button class="button" style="width: auto!important">Unggah Video Baru</button></a>
<table class="style1">
	<tr class="first">
		<td>No</td>
		<td>Video</td>
		<td>Judul</td>
		<td></td>
		<td></td>
		<td></td>
	</tr>
	<?php 
	$no = 1;
	if(count($videos) > 0){
		foreach($videos as $video){ ?>
		<tr>
			<td><?php echo $no;?></td>
			<td><?php echo get_thumbnail($video['url']);?></td>
			<td><?php echo $video['judul'];?></td>
			<td></td>
			<td><a title="Edit" class="edit_icon" href="<?php echo base_url();?>videos/edit/<?php echo $video['id_video'];?>"></a></td>
			<td><a title="Delete" class="delete_icon" href="" id_video ="<?php echo $video['id_video'];?>"></a></td>
		</tr>
		<?php 
		$no++;
		} 
	}else{
		echo '<tr><td colspan="6">Belum ada video yg diunggah.</td></tr>';
	}?>
</table>
</article>

<!--<article class="sidebar_right">
	<a href="#"><button class="pager active">1</button></a>
	<a href="#"><button class="pager">2</button></a>
	<a href="#"><button class="pager">3</button></a>
</article>-->

<div class="cleaner"></div>
</div>
<div class="cleaner"></div>
<?php $this->load->view('footer', $right_sidebar); ?>